package spring3.controller;
 
//import net.viralpatel.spring3.form.Contact;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import javax.validation.Valid;

import localhost.www2.service.application.servicio_ejemplo.servicio_ejemplosoa_php.Servicio1ServiceStub;
import localhost.www2.service.application.servicio_ejemplo.servicio_ejemplosoa_php.Servicio1ServiceStub.Galleta;
import localhost.www2.service.application.servicio_ejemplo.servicio_ejemplosoa_php.Servicio1ServiceStub.GalletaResponse;

import org.apache.axis2.AxisFault;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
 
@Controller
@SessionAttributes
public class ContactController {
 
    
    @RequestMapping(value = "/show" , method = RequestMethod.GET)   
	public ModelAndView helloWorld(String string) {

         
         try {

     		Servicio1ServiceStub oStub = new Servicio1ServiceStub();
        	Galleta cookie = new Galleta();
        	cookie.setSabor(string);
        	
     		
     		GalletaResponse objResponde =  oStub.galleta(cookie);
     		String retorno= objResponde.get_return();
     		
     		System.out.println(retorno);
     		
	         return new ModelAndView("show" , "message", retorno);
	         
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();

			return new ModelAndView("show", "message", "ERROR");
		}
        
	}

    @RequestMapping("/hello")
    public ModelAndView start() {    
        return new ModelAndView("hello", "message", "Inicio");
    }
    
}